﻿@using Pyramid.Bll
@using Pyramid.Extentions
@using Pyramid.Models
@using Pyramid.Mvc.Html
@model Staff
@{
	var account = (Account) ViewBag.Account;
	
	var roles = RoleHelper.NewInstance.GetRolesByUserType(UserTypes.Staff).Select(x => new IdTextModel {Id = x.RoleId, Text = x.RoleName});
	var selectedRoleIds = new List<int>();
	if (account.Roles != null)
	{
		selectedRoleIds = account.Roles.Select(x => x.RoleId).ToList();
	}
}
<div class="pageContent">
	@using (Html.BeginForm("SetAccount", "Staff", FormMethod.Post, new {@class = "pageForm required-validate", onsubmit = "return validateCallback(this, navTabAjaxDone);"}))
	{
		<div class="pageFormContent" layouth="60">
			@Html.Hidden("staffId", Model.Id)
			<p class="nowrap">
				@Html.LabelFor(model => model.Code)
				@Html.ReadonlyFieldFor(model => model.Code)
			</p>
			<p class="nowrap">
				@Html.LabelFor(model => model.FullName)
				@Html.ReadonlyFieldFor(model => model.FullName)
			</p>
			<div class="divider"></div>
			@Html.Partial("~/Views/Account/_AccountBaseInfoForm.cshtml", account)
			<div class="divider"></div>
			<p class="nowrap">
				<label>用户类型</label>
				<input type="text" readonly="readonly" value="@account.UserTypeEnum.ToDescription()"/>
			</p>
			<p class="nowrap">
				@Html.CheckBoxList("selectedRoleIds", "设定用户角色", selectedRoleIds, roles)
			</p>
		</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">保存</button>
						</div>
					</div>
				</li>
				<li>
					<div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	}
</div>
